package com.example.mobile2030606150cjk0421;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class CarAdapter extends RecyclerView.Adapter<CarAdapter.ViewHolder> {
    String[] names1;
    String[] names2;

    public CarAdapter(String[] names1, String[] names2) {
        this.names1 = names1;
        this.names2 = names2;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_car, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tv1.setText(names1[position]);
        holder.tv2.setText(names2[position]);

    }

    @Override
    public int getItemCount() {
        return names1.length;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tv1;
        TextView tv2;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            this.tv1 = itemView.findViewById(R.id.tvItemName1);
            this.tv2 = itemView.findViewById(R.id.tvItemName2);
    }
}}
